package com.itheima.sh.controller;

import com.itheima.sh.feign.FeignApi;
import com.itheima.sh.pojos.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Version: V1.0
 */
@RestController
@RequestMapping("feign")
public class FeignController {

    @Autowired
//    @Qualifier("feignApi")
    FeignApi feignApi;

    @GetMapping("{id}")
    //@HystrixCommand(fallbackMethod="queryByIdFallback")
    public User queryById(@PathVariable("id") String id){

        // Feign
        User user = feignApi.queryById(id);
        return user;
    }


    // 降级方法
//    public User queryByIdFallback(@PathVariable("id") String id) {
//        User user = new User();
//        user.setUsername(id);
//        user.setName("暂停服务");
//        return user;
//    }
}
